<!DOCTYPE html>
<html lang="zh" >
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
    <link rel="icon" type="image/x-icon" href="{{ asset('favicon64.ico') }}" />
    <title>{{ title }} manage3.0</title>
    {% block stylesheet %}
        {% stylesheets
            'bundles/icsocui/css/bootstrap.min.css'
            'bundles/icsocui/css/font-awesome.min.css'
            'bundles/icsocui/css/ace-fonts.css'
            'bundles/icsocui/css/ace-skins.min.css'
             filter="cssrewrite"
        %}
        <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}
    {% endblock %}

    {% block stylesheet_footer %}
        {% stylesheets
        'bundles/icsocui/css/ace.min.css'
        'bundles/icsocui/css/easyui.css'
        filter="cssrewrite"
        %}
        <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}
    {% endblock %}

    {%  block head_script %}
        {% javascripts
        'bundles/icsocui/js/ace-extra.min.js'
        filter='uglifyjs'
        %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
    {% endblock %}

    {% block statistic_script %}
        <script>
            var _hmt = _hmt || [];
            (function() {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?{{ baidu_statistic_sitecode }}";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
            window.zhuge = window.zhuge || [];window.zhuge.methods = "_init debug identify track trackLink trackForm page".split(" ");
            window.zhuge.factory = function(b) {return function() {var a = Array.prototype.slice.call(arguments);a.unshift(b);
                window.zhuge.push(a);return window.zhuge;}};for (var i = 0; i < window.zhuge.methods.length; i++) {
                var key = window.zhuge.methods[i];window.zhuge[key] = window.zhuge.factory(key);}window.zhuge.load = function(b, x) {
                if (!document.getElementById("zhuge-js")) {var a = document.createElement("script");var verDate = new Date();
                    var verStr = verDate.getFullYear().toString()+ verDate.getMonth().toString() + verDate.getDate().toString();
                    a.type = "text/javascript";a.id = "zhuge-js";a.async = !0;a.src = (location.protocol == 'http:' ? "http://sdk.zhugeio.com/zhuge.min.js?v=" : 'https://zgsdk.zhugeio.com/zhuge.min.js?v=') + verStr;
                    a.onerror = function(){window.zhuge.identify = window.zhuge.track = function(ename, props, callback){if(callback && Object.prototype.toString.call(callback) === '[object Function]')callback();};};
                    var c = document.getElementsByTagName("script")[0];c.parentNode.insertBefore(a, c);window.zhuge._init(b, x)}};
            window.zhuge.load('{{ zhuge_app_key }}');//配置应用的AppKey
        </script>
    {% endblock %}
</head>
<body class="{{ skin|default('no-skin') }}">
    {# 导航条 #}
    {{ include('IcsocUIBundle::navbar.html.twig') }}

    <div class="main-container" id="main-container">
        <script type="text/javascript">
            try{ace.settings.check('main-container', 'fixed')}catch(e){}
        </script>

        {# 左侧菜单 #}
        {{ include('IcsocUIBundle::sidebar.html.twig') }}

        {# 主内容区域 #}
        <div class="main-content">
            <div class="page-content" style="padding: 5px 20px 0 20px">
                <!-- setting box goes here if needed -->
                {{ include('IcsocUIBundle::setting.html.twig') }}
                <div id="tabs" class="tabbable"></div>
            </div><!-- /.page-content -->
        </div><!-- /.main-content -->

        <!-- footer area -->

    </div><!-- /.main-container -->
    <!-- list of script files -->
    {% block javascript %}
        <!--[if !IE]> -->
        <script src="{{ asset('bundles/icsocui/js/jquery.min.js') }}"></script>
        <!-- <![endif]-->
        <!--[if lte IE 9]>
        <script src="{{ asset('bundles/icsocui/js/jquery-1.11.1.min.js') }}"></script>
        <![endif]-->
        {% javascripts
        'bundles/icsocui/js/bootstrap.min.js'
        'bundles/icsocui/js/jquery.easyui.js'
        %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
    {% endblock %}

    {# 始终保持在最下面的javascript文件 #}
    {% block javascript_footer %}
        {% javascripts
        'bundles/icsocui/js/ace-elements.min.js'
        'bundles/icsocui/js/ace.min.js'
        filter='uglifyjs'
        %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
        <script type="application/javascript">
            $('#ace-settings-skin').on('change', function() {
                ace.settings.set('skin', this.value);
            });

            $(document).ready(function() {
                //创建仪表盘
                var fname = "{{ 'dashboard'|trans }}";
                var fheight = $(document).height() - 115;
                $('#tabs').tabs('add', {
                    title: fname,
                    iconCls: 'fa fa-tachometer',
                    closable:false,
                    fit: true,
                    content: '<iframe id="frame'+fname+' scrolling="auto" style="width:100%;height:'+fheight+'px" frameborder="0" src="{{ path('system_home_dashboard') }}"></iframe>'
                });
                $('a[datatype=tab]').on('click', function() {
                    addTab($(this));
                });
                $('iframe').height($(document).height() - 115);
                //tab控制
                $('#tabs').tabs({
                    border:false
                });
               ace.submenu.show('.first > .submenu');
            });

            /**
             * 添加tab
             */
            function addTab($obj)
            {
                var id = $obj.attr('data-id');
                var url = $obj.attr('data-url');
                var icon = $obj.attr('data-icon') || 'fa-bars';
                var title = $.trim($obj.text());
                var $tabs = $('#tabs');
                var height = $(document).height() - 115;
                $(".nav-list").find("li").attr("class", '');
                $($obj).parent().attr("class", "active");
                zhuge.track(title);
                if (!$tabs.tabs('exists', title)) {
                    $tabs.tabs('add', {
                        title: title,
                        iconCls: 'fa '+icon,
                        closable:true,
                        fit: true,
                        content: '<iframe id="frame'+id+'" scrolling="auto" style="width:100%;height:'+height+'px" frameborder="0" src="'+url+'"></iframe>'
                    });
                } else {
                    $tabs.tabs("select", title);
                    var tab = $tabs.tabs('getSelected');
                    $tabs.tabs('update', {
                        tab: tab,
                        options: {
                            content: '<iframe id="frame'+id+'" scrolling="auto" style="width:100%;height:'+height+'px" frameborder="0" src="'+url+'"></iframe>'
                        }
                    });
                }
            }

            /**
             * 在子页面用
             * @param name
             * @param url
             */
            function createTab(name, url)
            {
                var $tabs = $('#tabs');
                var height = $(document).height() - 115;
                zhuge.track(name);
                if (!$tabs.tabs('exists', name)) {
                    $tabs.tabs('add', {
                        title: name,
                        iconCls: 'fa fa-bars',
                        closable:true,
                        fit: true,
                        content: '<iframe id="frame'+name+'scrolling="auto" style="width:100%;height:'+height+'px" frameborder="0" src="'+url+'"></iframe>'
                    });
                } else {
                    $tabs.tabs("select", name);
                    var tab = $tabs.tabs('getSelected');
                    $tabs.tabs('update', {
                        tab: tab,
                        options: {
                            content: '<iframe id="frame'+name+'" scrolling="auto" style="width:100%;height:'+height+'px" frameborder="0" src="'+url+'"></iframe>'
                        }
                    });
                }
            }
            $('#tabs').tabs({
                onSelect:function(title,index){
                    if(index == 0){return;}
                    $(".nav-list").find("li").attr("class", 'hsub');
                    $('.nav-list ul').each(function(){
                        ace.submenu.hide($(this));
                    });
                    if ($.trim(title) == '参数设置' || $.trim(title) == '修改密码' || $.trim(title) == '帮助向导') {
                        return;
                    }
                    var lis = $("ul li:contains('"+ $.trim(title)+"')");
                    var length = lis.length;
                    $(lis[1]).attr('class', "active");
                    ace.submenu.show($(lis[1]).parent());
                    $(lis[1]).parent().parent().attr('class', 'open');
                    if (length == 4) {
                        $(lis[2]).attr('class', "active");
                        ace.submenu.show($(lis[2]).parent());
                    }
                }
            });
        </script>
    {% endblock %}
    {% block footer %}
    {% endblock %}
</body>
</html>